﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Xna.Framework.Graphics;
using ArtificialIntelligence;
using Microsoft.Xna.Framework.Content;
using Microsoft.Xna.Framework;
using PDS2;
using FarseerPhysics.Dynamics;

namespace PwnDatSkeleton2
{
    public class UnitManager
    {
        public List<Enemy> Enemies = new List<Enemy>();
        //public List<Bunny> Bunnies = new List<Bunny>();
        //public List<Monstercat> Monsterkitties = new List<Monstercat>();

        List<string> mobNames = new List<string>()
        {
            "monstercat",
            "wolf"
        };

        public UnitManager(Player player, ContentManager content, DamageDisplay dmgDsply, Random random, World world)
        {
            Enemies.Add(new Monstercat(player, random, new Vector2(2000, 2000), world));
            Enemies.Add(new Bunny(player, AIMode.FleeFrom, new Vector2(100, 400), world));

            foreach (Enemy e in Enemies)
            {
                if(e is Enemy)
                {
                    e.LoadDmgDisplay(dmgDsply);
                    e.LoadContent(content, mobNames[0]);
                }
                if (e is Bunny)
                {
                    e.LoadDmgDisplay(dmgDsply);
                    e.LoadContent(content, "Rabbit");
                }
            }
        }

        public void Update(GameTime gameTime)
        {
            for (int i = 0; i < Enemies.Count; i++)
            {
                Enemies[i].UpdateGameTime(gameTime);

                if (!Enemies[i].IsAlive)
                    Enemies.RemoveAt(i);
            }
        }

        public void Draw(SpriteBatch spriteBatch, GameTime gameTime)
        {
            foreach (Enemy enemy in Enemies)
            {
                enemy.Draw(spriteBatch);
            }

            //foreach (Monstercat monstercat in Monsterkitties)
            //{
            //    monstercat.Draw(spriteBatch);
            //}

            //foreach (Bunny bunny in Bunnies)
            //{
            //    bunny.Draw(spriteBatch);
            //}
        }
    }
}
